package com.fxd.crm.service.impl.courseImpl;

import com.fxd.crm.mapper.CourseOrderMapper;
import com.fxd.crm.mapper.courseMapper;
import com.fxd.crm.model.CourseOrder;
import com.fxd.crm.model.PageResult;
import com.fxd.crm.model.course;
import com.fxd.crm.service.ICourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @auther fuxudong
 * @date 2021/4/5 - 8:52
 */
@Service
public class courseImpl  implements ICourseService {
    @Autowired
    courseMapper courseMapper;


    @Override
    public PageResult<course> findPageResult(course course, int Page, int PageSize) {
        PageResult<course> result = new PageResult<>();
        result.setCode(0);
        Map<String, Object> params = new HashMap<>();
        params.put("condition",course);
        params.put("start",(Page-1)*PageSize);
        params.put("pageSize",PageSize);
        int count = courseMapper.findCountByMap(params);
        result.setCount(count);
        //获取查询的数据
        List<course> list = courseMapper.findListByMap(params);
        result.setData(list);
        System.out.println();
        return result;
    }

    @Override
    public void save(course course) {
        courseMapper.insert(course);
    }

    @Override
    public course findByOrderId(Integer course_id) {
        course course = courseMapper.findByOrderId(course_id);
        return course;
    }

    @Override
    public void deleteByOrderId(Integer course_id) {
        courseMapper.deleteByOrderId(course_id);
    }

    @Override
    public void update(course course) {
        courseMapper.update(course);
    }
}
